<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<!-- 顶部包含 -->
	<%@ include file="/pages/common/common.jsp" %>
<div class="container">
	<div class="panel panel-info">
		<div class="panel-heading">
		    <h3 class="panel-title">爬取过程分析</h3>
		</div>
		<div class="panel-body" id="procpanel">
		    <h1 id="resultdesc"></h1>
		    <table class="table table-hover" id="showtable">
		    <tr class="success"></tr>
			</table>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(function(){
		var param = new Object();
		param.method = "queryproc";
		$.ajax({
			url:"${ctx }/crawler",
			method:"POST",
			data:param,
			dataType:"json",
			success:function(data){
				if(data.success){
					var html = "<tr><th>书籍id</th><th>书籍名称</th><th>任务休眠时间(ms)</th><th>发生异常等待时间(s)</th><th>剩余章节数</th><th>操作</th></tr>";
					for(var i =0; i<data.object.length;i++){
						html += "<tr class='success'>";
						html += "<td>"+data.object[i].bookid+"</td>";
						html += "<td>"+data.object[i].bookname+"</td>";
						html += "<td>"+data.object[i].delay+"</td>";
						html += "<td>"+data.object[i].sleep+"</td>";
						html += "<td>"+data.object[i].remainSize+"</td>";
						html += "<td  onclick=remove('"+data.object[i].bookid+"','"+data.object[i].remainSize+"')><span class='glyphicon glyphicon-remove'></span>&nbsp;&nbsp;清除</td>";
						html +="</tr>";
					}
					$("#showtable").append(html);
				}else{
					$("#resultdesc").html(data.resultdesc);
				}
			},
		})
	})
	
	
	function remove(bookid,remain){
		if(remain == 0){
			alert(bookid);
		}else{
			alert("不能清除正在抓取的项目，如需终止请前往中断页面");
		}
		
	}
	
</script>

</body>
</html>